#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

while True:
    bignum = 50
    n_iter = 0
    with display_block('Entradas'):
        R2 = h = (One * oneof(1, 2, 3, 4)) / oneof(1, 2, 3, 4)
        A = sqrt(h)

        a = (One * oneof(1, 1, -1) * oneof(1, 2, 3, 4, 5, 6))
        a /= oneof(1, 2, 3, 4, 5, 6)
        b = (One * oneof(1, 2, 3, 4, 5, 6)) / oneof(1, 2, 3, 4, 5, 6)

        F = Fx, Fy, Fz = (a * x - y), (a * y + x), b

    # Resultados
    with display_block('Resultados'):
        Phi = (2 * A ** 2 * pi * (2 * a * A / 3 + b / 2)).expand()
        PhiLim = (8 * a * A ** 3 * pi / 3).expand()
        PhiFechado = (4 * a * A ** 3 * pi / 3).expand()
        PhiJacob = (A ** 2 * pi ** 2 * a).expand()
        PhiElem = (4 * A ** 2 * b * pi).expand()

        PhiNeg = -Phi
        PhiJacobNeg = -PhiJacob
        PhiLimNeg = -PhiLim
        PhiElemNeg = -PhiElem
        PhiFechadoNeg = -PhiFechado

        if len(set([Phi, -Phi, PhiJacob, -PhiJacob, PhiLim, -PhiLim, PhiElem,
                    - PhiElem, PhiFechado, -PhiFechado])) != 10:
            continue

        n_iter += 1
    break
